{
  "properties" : { },
  "id" : "791adddc9276440bade60b00bc8bd5b0",
  "script" : null,
  "groupId" : "74af8e1135d2474eb9b6b4081e6d5967",
  "name" : "查询左侧树形结构",
  "createTime" : 1727071037131,
  "updateTime" : 1727064106717,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "queryTopoGroupTree",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": [\n        {\n            \"id\": \"1\",\n            \"parentId\": \"9999\",\n            \"groupName\": \"陕西省调1\",\n            \"sort\": 1,\n            \"remark\": \"\",\n            \"lv\": 1,\n            \"dccId\": \"1793494418083319810\",\n            \"deviceCount\": 64,\n            \"children\": [\n                {\n                    \"id\": \"3\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"骨干二平面\",\n                    \"sort\": 2,\n                    \"remark\": \"骨干二平面\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 13,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"4\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"东郊变接入\",\n                    \"sort\": 91,\n                    \"remark\": \"东郊变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 18,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"5\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"大杨变接入\",\n                    \"sort\": 92,\n                    \"remark\": \"大杨变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 29,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"7\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"延安变接入\",\n                    \"sort\": 93,\n                    \"remark\": \"延安变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 75,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"8\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"榆林变接入\",\n                    \"sort\": 94,\n                    \"remark\": \"榆林变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 61,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"9\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"榆横-夏州汇聚接入\",\n                    \"sort\": 95,\n                    \"remark\": \"榆横-夏州汇聚接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 63,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"10\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"榆横变接入\",\n                    \"sort\": 96,\n                    \"remark\": \"榆横变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 93,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"11\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"信义变接入\",\n                    \"sort\": 97,\n                    \"remark\": \"信义变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 96,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"13\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"朔方变接入\",\n                    \"sort\": 99,\n                    \"remark\": \"朔方变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 111,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"14\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"泾渭变接入\",\n                    \"sort\": 100,\n                    \"remark\": \"泾渭变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 38,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"15\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"鹤城变接入\",\n                    \"sort\": 101,\n                    \"remark\": \"鹤城变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 62,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"16\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"南山变接入\",\n                    \"sort\": 102,\n                    \"remark\": \"南山变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 75,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"17\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"汉中变接入\",\n                    \"sort\": 103,\n                    \"remark\": \"汉中变接入\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 155,\n                    \"children\": []\n                },\n                {\n                    \"id\": \"2\",\n                    \"parentId\": \"1\",\n                    \"groupName\": \"骨干一平面\",\n                    \"sort\": 2,\n                    \"remark\": \"骨干一平面\",\n                    \"lv\": \"\",\n                    \"dccId\": \"1793494418083319810\",\n                    \"deviceCount\": 13,\n                    \"children\": []\n                }\n            ]\n        },\n        {\n            \"id\": \"12\",\n            \"parentId\": \"9999\",\n            \"groupName\": \"延安地调\",\n            \"sort\": 1,\n            \"remark\": \"延安地调\",\n            \"lv\": 2,\n            \"dccId\": \"1803254752905129985\",\n            \"deviceCount\": 35,\n            \"children\": [\n                {\n                    \"id\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                    \"parentId\": \"12\",\n                    \"groupName\": \"第一接入网\",\n                    \"sort\": 2,\n                    \"remark\": \"\",\n                    \"lv\": 1,\n                    \"dccId\": \"1803254752905129985\",\n                    \"deviceCount\": 3,\n                    \"children\": [\n                        {\n                            \"id\": \"96f14d82-2e5d-4d37-a970-67f16bea7cce\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"志丹\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 42,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"439cb9c4-8af1-44f3-b5b2-b734520525ad\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"子长\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 36,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"a23d35c7-e530-4163-b370-c1ebeaa8e755\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"吴起\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 41,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"6c01ffad-5390-45c8-bf33-0091bd088fb5\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"安塞\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 39,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"c2a214ea-31e7-4aed-bf46-69dba944f7ab\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"延川\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 42,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"91c9eb30-6d63-4967-8b5e-1265e59826a0\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"宝塔区\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 81,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"51ab1401-3074-4d90-8802-8fca57b0ff79\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"甘泉\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 21,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"1e6173ad-b40b-46dc-9add-8d8db7211844\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"延长\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 30,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"ccc4c9a3-452a-4b03-bc2b-91d9d75a150e\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"富县\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 36,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"54fe36b0-5a51-4f71-9877-d280eedef1b0\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"黄陵\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 60,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"e30ce304-d2d3-41ad-a64d-a9e9915d7e38\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"洛川\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 30,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"af80eac0-f9db-42c5-99bf-6d88bd44e0a7\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"黄龙\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 10,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"9b662e93-76c5-4836-bd49-e2424168613f\",\n                            \"parentId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\n                            \"groupName\": \"宜川\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 21,\n                            \"children\": []\n                        }\n                    ]\n                },\n                {\n                    \"id\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                    \"parentId\": \"12\",\n                    \"groupName\": \"第二接入网\",\n                    \"sort\": 2,\n                    \"remark\": \"\",\n                    \"lv\": 1,\n                    \"dccId\": \"1803254752905129985\",\n                    \"deviceCount\": 3,\n                    \"children\": [\n                        {\n                            \"id\": \"f532f70a-5642-480e-8a39-3dabfb4caafc\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"子长\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 36,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"efbe802a-d84a-4bdd-b83e-8fe788068b08\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"宝塔区\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 71,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"3e36d5c2-9208-4048-92b8-cf1bfd0359eb\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"宜川\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 21,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"6ed8c37a-7636-4714-9008-5d5a5715f4f8\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"黄龙\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 9,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"ff943c99-f58f-42f8-9ec9-61204cdb9619\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"吴起\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 39,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"3d698470-86da-42d3-b22b-b67762f20809\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"志丹\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 39,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"8143b5ae-2f3f-41b6-8f20-dbf8bfa8ec8d\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"安塞\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 39,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"e23a6082-5133-4b65-9fdd-3d5e5840734c\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"延川\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 34,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"726c6d6c-0218-4f09-8fce-bb90dcad5c86\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"甘泉\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 21,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"3fd44d58-3261-4ab8-9db0-37187a9dd500\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"延长\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 27,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"0ceecc79-3c41-47f3-9363-eb6b1f432ecb\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"富县\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 36,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"cb295933-ade4-4d9d-9030-d33cfb058062\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"黄陵\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 39,\n                            \"children\": []\n                        },\n                        {\n                            \"id\": \"0ae0d932-16ad-49f7-986c-219d6bf389a9\",\n                            \"parentId\": \"4ae7048a-8e53-411c-8a20-061bcf192866\",\n                            \"groupName\": \"洛川\",\n                            \"sort\": \"\",\n                            \"remark\": \"\",\n                            \"lv\": 3,\n                            \"dccId\": \"1803254752905129985\",\n                            \"deviceCount\": 23,\n                            \"children\": []\n                        }\n                    ]\n                }\n            ]\n        },\n        {\n            \"id\": \"9640f822-c8eb-4a84-a824-07c0d2764cbb\",\n            \"parentId\": \"9999\",\n            \"groupName\": \"ceshi1\",\n            \"sort\": \"\",\n            \"remark\": \"\",\n            \"lv\": \"\",\n            \"dccId\": \"1793494418083319810\",\n            \"children\": []\n        }\n    ]\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
import "@/util/findChildrenTopo" as findChildrenTopo
import redis

//   var token = header.get("blade-auth")::string;
//   var dccId = redis.get(token.substring(7))
// 上面两行替换成下面代码
var dccId = getDccId()::string

List result = new ArrayList();
// 查询条件需要先判断dcc_id是否为空
List ndmpGroupVoList = db.table("ndmp_group").where().eq(!is_blank(dccId), "dcc_id", dccId).select();

List listCount = db.select("""
SELECT group_id key_str, count(1) value_str
    FROM ndmp_group_device_relation
    GROUP BY group_id
""")

for (ndmpGroupVo in ndmpGroupVoList) {
    if ("9999".equals(ndmpGroupVo.get("parentId"))) {
        listCount.stream().filter(v -> v.get("keyStr").equals(ndmpGroupVo.get("id"))).findAny().ifPresent(v -> ndmpGroupVo.put("deviceCount", v.get("valueStr")::int));
        result.add(ndmpGroupVo);
    }
}
findChildrenTopo(result, ndmpGroupVoList, listCount);

return result